package h0731;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
  * @description 换汽水问题
  * @author 不知名帅哥
  * @date 2024/7/31 20:12
  * @version 1.0
*/
public class Test2 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        List<Integer> list=new ArrayList<>();
        while (sc.hasNextInt()){
            int n = sc.nextInt();
            if (n==0) break;
            list.add(n);
        }
        for (Integer i : list) {
            System.out.println(maxBottles(i));
        }
    }

    private static int maxBottles(int n) {
        //空瓶数量除以3，
        int sum=0;
        while (n>2){
            int remainder=n/3;
            sum+=remainder;
            n=remainder+n%3;
        }
        if (n+1==3){
            sum+=1;
        }
        return sum;
    }
}
